from rest_framework import serializers
from .models import *

class UserSerializer(serializers.ModelSerializer):
    class Meta:
        model = User
        fields = '__all__'

class ThirdSerializer(serializers.ModelSerializer):
    type_name = serializers.CharField(source='get_type_display', read_only=True)
    class Meta:
        model = ThirdUser
        fields = '__all__'



class GoodsCategorySerializer(serializers.ModelSerializer):
    class Meta:
        model = GoodsCategory
        fields = '__all__'

class GoodsSerializer(serializers.ModelSerializer):
    category_name = serializers.CharField(source='category.name', read_only=True)
    class Meta:
        model = Godds
        fields = '__all__'

class UserBrowserHistorySerializer(serializers.ModelSerializer):
    goods_name = serializers.CharField(source='goods.name', read_only=True)
    user_name = serializers.CharField(source='user.name', read_only=True)
    class Meta:
        model = UserBrowse
        fields = '__all__'